import useAntdList from '@/hooks/useAntdList';
import { AntdModalProps } from '@/hooks/useAntdModal';
import { queryRecord } from '@/service/globalSetting';
import { Button, Form, Modal, Table } from 'antd';
import { ColumnsType } from 'antd/lib/table';
import React, { useEffect } from 'react';
const RecordModal = ({ modalProps }: AntdModalProps) => {
  const { tableProps, run } = useAntdList(queryRecord, {
    manual: true
  })
  useEffect(() => {
    if (modalProps.open) {
      //   @ts-ignore
      run();
    }

  }, [modalProps.open])
  const columns: ColumnsType<any> = [{
    title: 'noticeTitle',
    dataIndex: 'noticeTitle'
  }, {
    title: '创建时间',
    dataIndex: 'createdAt'
  }, {
    title: 'body',
    width: 100,
    render(_) {

      return <Button type='link' onClick={e => {
        Modal.info({
          title: 'body',
          content: <div>
            <pre>
              {JSON.stringify(JSON.parse(_.body) , null, 4)}
            </pre>
          </div>
        })
      }}>查看</Button>
    }
    // dataIndex: 'body'
  }
  ]
  return (<Modal width={800} {...modalProps}>
    <Table rowKey='id' {...tableProps} columns={columns} />
  </Modal>)
}
export default RecordModal